﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cfg.Attributes;
using Cfg.ConfigProviders;
using Cfg.ConfigValues;
using NUnit.Framework;

namespace Cfg.Test.Providers
{
    [TestFixture]
    public class IniProviderTest
    {
        public interface ICfg
        {
             bool Bool1 { get; }
             bool Bool2 { get; }
             bool Bool3 { get; }
             bool Bool4 { get; }

            IOwnerSection Owner { get; }
            IDatabaseSection Database { get; }
        }

        public interface IOwnerSection
        {
            string Name { get; }
            string Organization { get; }
        }

        public interface IDatabaseSection
        {
            string Server { get; }
            int Port { get; }

            [Path(false, false, IsFilePath = true)]
            PathInfo File { get; }
        }

        [Test]
        public void Test()
        {
            try
            {
                AppSettings.Init<ICfg>(new IniFileProvider("test.ini"));
            }
            catch (Exception)
            {
                var cfg = AppSettings.Get<ICfg>();
                throw;
            }
        }

        [Test]
        public void GetDictionary()
        {
            var provider = new IniFileProvider("test.ini");

            var kvps = provider.GetValues();

            foreach (var kvp in kvps)
            {
                Console.WriteLine("{0}: {1}", kvp.Key, kvp.Value);
            }
        }
    }
}
